﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using DevExpress.XtraReports.Configuration;
using DevExpress.XtraReports;
using DevExpress.XtraReports.UI;
using DevExpress.LookAndFeel;

namespace COMOSOFT.JobManagement.Froms
{
    public partial class FrmJobStatistic : Form
    {
        DateTime FromDate,ToDate;
        public FrmJobStatistic()
        {
            InitializeComponent();
        }

        private void dataNavigator_Job_ButtonClick(object sender, DevExpress.XtraEditors.NavigatorButtonClickEventArgs e)
        {
            switch (e.Button.Tag.ToString())
            {
                case "Print":
                    Report.JobStatisticReport rptJobStatistic = new Report.JobStatisticReport(FromDate,ToDate);
                    ReportPrintTool printTool = new ReportPrintTool(rptJobStatistic);
                    printTool.ShowRibbonPreview(UserLookAndFeel.Default);
                    break;
                case "Refresh":
                    sp_JobStatisticTableAdapter.Fill(dataSet_JobManagement.sp_JobStatistic,FromDate,ToDate);                   
                    break;
            }
        }

        private void bnt_Preview_Click(object sender, EventArgs e)
        {
            FromDate =Convert.ToDateTime(txt_FromDate.EditValue);
            ToDate =Convert.ToDateTime(txt_ToDate.EditValue);
            sp_JobStatisticTableAdapter.Fill(dataSet_JobManagement.sp_JobStatistic, FromDate, ToDate);
            panel_JobFailed.Visible = true;
        }

        private void FrmJobStatistic_Load(object sender, EventArgs e)
        {
            txt_FromDate.EditValue = DateTime.Now;
            txt_ToDate.EditValue = DateTime.Now;
        }
    }
}
